#ifndef KEYMANAGER
#define KEYMANAGER
#include "BJ.h"

typedef void (*KeyManagerCallback)(int Value, bool Flag);

class KeyManager
{
    public:
        KeyManager
        (
            void
        )
        {
            _value = 0;
            _function = NULL;
        }
        ~KeyManager
        (
            void
        )
        {
        
        }
        
        static bool register_key
        (
            int id,
            int value,
            void (*function)(int, bool)
        )
        {
            if(Array[id]._function == NULL)
            {
                Array[id]._value = value;
                Array[id]._function = function;
                return true;
            }
            else
            {
                return false;
            }
        }
        
        static void refresh(void)
        {
            int z;
            for(z = 0;z < 0xFF;z++)
            {
                if(Array[z]._function != NULL)
                {
                    Array[z]._function(Array[z]._value,GetAsyncKeyState(z));
                }
            }
        }
    private:
    
    int _value;
    KeyManagerCallback _function;
    static KeyManager Array[0xFF];
};
KeyManager KeyManager::Array[] = {KeyManager()};

#endif